-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid warning 'calling IsSet with unsupported type "invalid" (<nil>)' #1465
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this.
There's a simpler way to resolve such expressions, for example:
{{ $sidebarCacheLimit := and .Site.Params.ui .Site.Params.ui.sidebar_cache_limit | default 2000 -}}
It's might be a good idea to also include a test of .Site.Params
since that section is absent when, for example, hugo creates a new site.
{{ $sidebarCacheLimit := and .Site.Params .Site.Params.ui .Site.Params.ui.sidebar_cache_limit | default 2000 -}}
Could you change all assignment expressions to be of this form?
Thanks for reviewing this promptly.
Great idea. I don't see, however, why we additionally should evaluate
This is also what the official documentation suggests.
Done. Meanwhile, I fixed a few unwanted warnings with taxonomies, too. |
Have you tested your solution with the |
Yes, I did, an it returned the default value, as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange. It is as if Hugo's .
is acting as a safe selector (like .?
in some other languages). I don't think it was always like that, but I'm happy that it works now. Thanks for fixing this.
It might be worth fixing the other occurrences in the use of "isset"? |
This PR addresses #1464.
As pointed out in #608 already, the root cause of the warning is the wrong use of
isset
.This PR replaces
isset
and useswith
clauses instead, thus avoiding the confusing warn messages.This PR closes #1464.